import { mapState } from "vuex";

module.exports = {
  computed: {
    ...mapState(["vuex_user_id", "vuex_share_id"]),
  },
  onLoad(options) {
    if (options.shareid) {
      this.$u.vuex("vuex_share_id", options.shareid);
    };
    // this.$u.toast("分享人id：" + this.vuex_share_id);
  },
  onShow() {
    // this.$t.toast("用户id：" + this.vuex_user_id);
    // 分享
    let pages = getCurrentPages(); // 获取加载的页面
    if (pages.length) {
      let currentPage = pages[pages.length - 1];
      let _url = currentPage.$page.fullPath;
      _url = _url.startsWith("/") ? _url : "/" + _url;
      _url = _url.includes("?") ? _url + "&shareid=" + this.vuex_user_id || "" : _url + "?shareid=" + this.vuex_user_id || "";
      // console.log(_url);
      this.$share = {
        title: "御律法务",
        path: _url,
        imageUrl: ""
      };
    }
  },
  onShareAppMessage() {
    return this.$share
  }
}